<?php
namespace zake\foundation\able\stream;

use zake\foundation\able\ProtocolAble;

interface ReadAble extends ResourceAble
{
    /**
     * 读
     * @return resource
     *
     * @author liu.bin 2020-03-31 16:33
     */
    public function getReadResource();


    /**
     *
     * @return int
     *
     * @author liu.bin 2020-04-16 09:28
     */
    public function getReadFd();

    /**
     *
     * @return bool
     *
     * @author liu.bin 2020-04-26 10:38
     */
    public function closeReadResource();


    /**
     *
     * @return bool
     *
     * @author liu.bin 2020-04-26 10:38
     */
    public function isCloseReadResource();


    /**
     * 设定读取时间
     *
     * @param int|null $time
     * @author liu.bin 2020-03-31 16:43
     */
    public function setReadTime($time=null);


    /**
     * 获取上一次接收数据的时间
     *
     * @return int
     * @author liu.bin 2020-03-28 21:18
     */
    public function getReadTime();


    /**
     * 同步读取
     * @param ProtocolAble $protocol
     * @param null $closeCallback
     * @param string $buffer
     * @return mixed
     *
     * @author liu.bin 2020-05-19 17:15
     */
    public function read(ProtocolAble $protocol,$closeCallback=null,$buffer = "");


}